//
//  WHFishSpotHeaderView.m
//  WHEasyBizLink
//
//  Created by ShengMeng on 9/19/25.
//

#import "WHFishSpotHeaderView.h"
#import "SVProgressHUD.h"
#import <sys/utsname.h>
#import "CommonTools.h"
#import "SDAutoLayout.h"
#import "ZWMSegmentView.h"
#import "WHSelecetBtn.h"


@interface WHFishSpotHeaderView ()

/**    地址  */
@property (nonatomic, weak)UIImageView *addressImage;

@property (nonatomic, weak)UIButton* addressBtn;

/**   温度 */
@property (nonatomic,weak)UILabel * temperaturLabel;

/**   天气 */
@property (nonatomic, weak)UIImageView *weatherImage;

/**   天气 */
@property (nonatomic,weak)UILabel * weatherLabel;

@property (nonatomic, weak)UIButton* applyBtn;
@property (nonatomic, strong)ZWMSegmentView*segmentView;
@property (nonatomic, strong)WHSelecetBtn*selecetBtn;


@end

@implementation WHFishSpotHeaderView

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setUpAllChilds];
        
        self.backgroundColor=[UIColor clearColor];
    }
    return self;
}

-(void)setUpAllChilds
{
    
//    UIImageView*addressImage = [[UIImageView alloc]init];
//    addressImage = [[UIImageView alloc] init];
//    addressImage.image = [UIImage imageNamed:@"dizhi"];
//    self.addressImage = addressImage;
//    [self addSubview:addressImage];
//    
//    UIButton* addressBtn= [[UIButton alloc]init];
//    [addressBtn setTitleColor:[UIColor colorWithHexString:@"#767676" alpha:1.0] forState:UIControlStateNormal];
//    [addressBtn setTitle:@"深圳市" forState:UIControlStateNormal];
//    
//    addressBtn.titleLabel.font = [UIFont systemFontOfSize:14];
//    [self addSubview:addressBtn];
//    _addressBtn = addressBtn;
//
//    /**    气温  */
//    UILabel *temperaturLabel = [[UILabel alloc]init];
//    temperaturLabel.text = @"当前气温  28℃";
//    [self addSubview:temperaturLabel];
//    temperaturLabel.font = [UIFont systemFontOfSize:14];
//    temperaturLabel.textColor = [UIColor colorWithHexString:@"#767676" alpha:1.0];
//    _temperaturLabel = temperaturLabel;
//    
//    UIImageView*weatherImage = [[UIImageView alloc]init];
//    weatherImage = [[UIImageView alloc] init];
//    weatherImage.image = [UIImage imageNamed:@"weather"];
//    self.weatherImage = weatherImage;
//    [self addSubview:weatherImage];
//    
//    UILabel *weatherLabel = [[UILabel alloc]init];
//    weatherLabel.text = @"阴天";
//    weatherLabel.font = [UIFont systemFontOfSize:14];
//    weatherLabel.textColor = [UIColor colorWithHexString:@"#767676" alpha:1.0];
//    [self addSubview:weatherLabel];
//    _weatherLabel = weatherLabel;
    
    UIButton* applyBtn= [[UIButton alloc]init];
    [applyBtn setTitleColor:[UIColor colorWithHexString:@"#767676" alpha:1.0] forState:UIControlStateNormal];
    [applyBtn setBackgroundImage:[UIImage imageNamed:@"apply"] forState:UIControlStateNormal];
    [self addSubview:applyBtn];
    _applyBtn = applyBtn;
    
    _segmentView = [[ZWMSegmentView alloc] initWithFrame:CGRectMake(20, self.height-80,self.width-40,45) titles:@[@"全部钓场",@"关注钓场",@"赛事钓场",@"推荐钓场",@"新开钓场",@"黑坑钓场",@"湖库钓场",@"竞技钓场",@"路亚钓场"]];
    [_segmentView setSelectedAtIndex:0];
    _segmentView.backgroundColor=[UIColor clearColor];
   // __weak __typeof(self) weakSelf = self;
    [_segmentView selectedAtIndex:^(NSUInteger index, UIButton * _Nonnull button) {
        //[weakSelf.segmentView  adjustOffsetXToFixIndicatePosition: button.centerX];
    }];
    [self addSubview:_segmentView];
    
    
    WHSelecetBtn*fishSelecetBtn =[[WHSelecetBtn alloc]initWithFrame:CGRectMake(30, self.height-30,self.width-60,30)];
    fishSelecetBtn.tag = 1;
    [fishSelecetBtn setTitleColor:[UIColor colorWithHexString:@"#767676" alpha:1.0] forState:UIControlStateNormal];
    [fishSelecetBtn addTarget:self action:@selector(selecetBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [fishSelecetBtn setViewTitleBtnWithTitle:@"目标鱼种"];
    [self addSubview:fishSelecetBtn];
    
    
    WHSelecetBtn*selecetBtn =[[WHSelecetBtn alloc]initWithFrame:CGRectMake(CGRectGetMaxX(fishSelecetBtn.frame)+20, self.height-30,self.width-60,30)];
    selecetBtn.tag = 2;
    [selecetBtn setTitleColor:[UIColor colorWithHexString:@"#767676" alpha:1.0] forState:UIControlStateNormal];
    [selecetBtn addTarget:self action:@selector(selecetBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [selecetBtn setViewTitleBtnWithTitle:@"钓场钓法"];
    [self addSubview:selecetBtn];

    [self setUpLayout];
   
}
-(void)setUpLayout
{
//    _addressImage
//    .sd_layout
//    .topSpaceToView(self,10)
//    .leftSpaceToView(self,20)
//    .widthIs(20)
//    .heightIs(20);
//    
//    _addressBtn
//    .sd_layout
//    .topSpaceToView(self,10)
//    .leftSpaceToView(self.addressImage,0)
//    .widthIs(60)
//    .heightIs(20);
//    
//    _temperaturLabel.sd_layout
//    .topSpaceToView(self, 10)
//    .leftSpaceToView(self.addressBtn,0)
//    .widthIs(100)
//    .heightIs(20);
//    
//    _weatherImage
//    .sd_layout
//    .topSpaceToView(self,10)
//    .leftSpaceToView(_temperaturLabel,10)
//    .widthIs(20)
//    .heightIs(20);
//    
//    _weatherLabel
//    .sd_layout
//    .topSpaceToView(self,10)
//    .leftSpaceToView(_weatherImage,10)
//    .widthIs(40)
//    .heightIs(20);
    
    _applyBtn
    .sd_layout
    .topSpaceToView(self,10)
    .leftSpaceToView(self,20)
    .rightSpaceToView(self,20)
    .heightIs(120);
    
}

-(void)selecetBtnClick:(UIButton*)btn
{
    
    if ([_delegate respondsToSelector:@selector(wHFishSpotHeaderViewwBtnClick:)]) {
        [_delegate wHFishSpotHeaderViewwBtnClick:btn];
    }

}


@end
